import { getAreaObj, uploadType, regularRule } from '@/utils/util'

const isVerify = true

const nameObj = {
	社区老年人认知障碍照护服务中心: 'nurseConstructionStatus',
	助餐点: 'constructionStatus',
	睦邻点: 'neighborlyConstructionStatus',
}
export const searchAidConfig = (title) => {
	return {
		inline: true,
		showBtn: true,
		labelPosition: 'left',
		column: [
			{
				label: '所属区域',
				prop: 'crAreas',
				type: 'AplidAreaSelect',
				span: 8,
			},
			{
				label: '设施名称',
				prop: 'soleValue',
				span: 8,
			},
			{
				label: '建立日期',
				prop: 'foundDateBetween',
				type: 'dateBetween',
				format: 'YYYY年MM月DD日',
				valueFormat: 'YYYY-MM-DD HH:mm:ss',
				changeField: true,
				span: 8,
			},
			{
				label: '改造进度',
				prop: nameObj[title],
				propName: nameObj[title]+'Label',
				type: 'remoteSelect',
				code: 'CONSTRUCTION_STATUS',
				api: 'getDictItemList',
				filterKey: 'value',
				multiple: false,
				span: 8,
			},
			{
				label: '营业状态',
				prop: 'state',
				propName: 'stateLabel',
				type: 'remoteSelect',
				code: 'BUSINESS_STATUS',
				api: 'getDictItemList',
				filterKey: 'value',
				multiple: false,
				changeField: true,
				span: 8,
			},
			{
				label: '区级民政部门认定挂牌',
				prop: 'isListingPhoto',
				type: 'select',
				dicData: [
					{ label: '未上传', value: '0' },
					{ label: '已上传', value: '1' },
				],
				span: 8,
			},
		],
	}
}

export const tableAidConfig = (title) => {
	return {
		stripe: true,
		border: true,
		maxHeight: '80vh',
		columns: [
			{
				label: '所属区域',
				prop: 'tableAreaName',
				width: 200,
			},
			{ label: '设施名称', prop: 'soleValue' },
			{ label: '建立日期', prop: 'foundDate' },
			{ label: '改造进度', prop: nameObj[title], code: 'CONSTRUCTION_STATUS' },
			{
				label: '营业状态',
				prop: 'stateLabel',
			},
			{
				label: '区级民政部门认定挂牌',
				prop: 'isListingPhotoLabel',
			},
			{
				label: '操作',
				prop: 'menu',
				width: 200,
				fixed: 'right',
			},
		],
	}
}

export const tableReformConfig = {
	stripe: true,
	border: true,
	maxHeight: '80vh',
	columns: [
		{ label: '所属区', prop: 'crAreaName' },
		{ label: '姓名', prop: 'name' },
		{ label: '证件号码', prop: 'idCard', plusXing: '2,2' },
		{ label: '联系方式', prop: 'phone', plusXing: '5,2' },
		{
			label: '类别',
			prop: 'categoryLabel',
		},
		{
			label: '申请档案',
			prop: 'applyState',
			propName: 'applyStateLabel',
			type: 'remoteSelect',
			api: 'getDictItemList',
			code: 'ARCHIVES_STATUS',
		},
		{
			label: '评估档案',
			prop: 'assessState',
			propName: 'assessStateLabel',
			type: 'remoteSelect',
			api: 'getDictItemList',
			code: 'ARCHIVES_STATUS',
		},
		{
			label: '改造档案',
			prop: 'remouldState',
			propName: 'remouldStateLabel',
			type: 'remoteSelect',
			api: 'getDictItemList',
			code: 'ARCHIVES_STATUS',
		},
		{
			label: '验收档案',
			prop: 'acceptanceState',
			propName: 'acceptanceStateLabel',
			type: 'remoteSelect',
			api: 'getDictItemList',
			code: 'ARCHIVES_STATUS',
		},
		{
			label: '操作',
			prop: 'menu',
			width: 300,
			fixed: 'right',
		},
	],
}

export const tableFamilyConfig = {
	stripe: true,
	border: true,
	maxHeight: '80vh',
	columns: [
		{ label: '所属区', prop: 'crAreaName' },
		{ label: '姓名', prop: 'name' },
		{ label: '证件号码', prop: 'idCard', plusXing: '2,2' },
		{ label: '联系方式', prop: 'phone', plusXing: '5,2' },
		{
			label: '类别',
			prop: 'userType',
			propName: 'userTypeLabel',
			type: 'remoteSelect',
			api: 'getDictItemList',
			code: 'ELDERLY_TYPE',
		},
		{
			label: '申请档案',
			prop: 'applyState',
			propName: 'applyStateLabel',
			code: 'ARCHIVES_STATUS',
			api: 'getDictItemList',
			type: 'remoteSelect',
		},
		{
			label: '评估档案',
			prop: 'assessState',
			propName: 'assessStateLabel',
			code: 'ARCHIVES_STATUS',
			api: 'getDictItemList',
			type: 'remoteSelect',
		},
		{
			label: '签约档案',
			prop: 'signState',
			propName: 'signStateLabel',
			code: 'ARCHIVES_STATUS',
			api: 'getDictItemList',
			type: 'remoteSelect',
		},
		{
			label: '改造档案',
			prop: 'remouldState',
			propName: 'remouldStateLabel',
			code: 'ARCHIVES_STATUS',
			api: 'getDictItemList',
			type: 'remoteSelect',
		},
		{
			label: '验收档案',
			prop: 'acceptanceState',
			propName: 'acceptanceStateLabel',
			code: 'ARCHIVES_STATUS',
			api: 'getDictItemList',
			type: 'remoteSelect',
		},
		{
			label: '操作',
			prop: 'menu',
			width: 300,
			fixed: 'right',
		},
	],
}

export const facilityFormConfig = (obj?: any) => {
	return {
		label: '基础信息',
		prop: 'base0',
		inline: false,
		showBtn: false,
		labelPosition: 'top',
		column: [
			{
				label: '设施名称',
				prop: 'soleValue',
				type: 'text',
				maxlength: '50',
				showWordLimit: true,
				editDisabled: true,
				span: 8,
				rules: isVerify ? [{ required: 'true', message: '请输入设施唯一值' }] : [],
			},
			{
				label: '设施类型',
				prop: 'type',
				propName: 'typeLabel',
				type: 'remoteSelect',
				span: 8,
				code: 'FACILITY_TYPE',
				api: 'getDictItemList',
				filterKey: 'value',
				multiple: true,
				changeField: true,
				defaultValue: obj.type,
				rules: isVerify ? [{ required: 'true', message: '请选择设施类型' }] : [],
				control: (_, model) => {
					return {
						dailyDeliveryOfFoodAid: {
							display: model.type?.includes('10'),
						},
						centralKitchenStoveType: {
							display: model.type?.includes('4'),
						},
						isInstallGasLeakageSafeDevice: {
							display: model.type?.includes('4'),
						},
						constructionDate: {
							display: model.type?.includes('11'),
						},
						constructionStatus: {
							display: model.type?.includes('11'),
						},
						neighborlyConstructionDate: {
							display: model.type?.includes('13'),
						},
						neighborlyConstructionStatus: {
							display: model.type?.includes('13'),
						},
						nurseConstructionDate: {
							display: model.type?.includes('9'),
						},
						nurseConstructionStatus: {
							display: model.type?.includes('9'),
						},
					}
				},
			},
			{
				label: '是否独立占地',
				prop: 'isIndependentLandOccupation',
				propName: 'isIndependentLandOccupationLabel',
				type: 'remoteSelect',
				api: 'getDictItemList',
				code: 'COMMON_FLAG',
				filterKey: 'value',
				multiple: false,
				changeField: true,
				span: 8,
				rules: isVerify ? [{ required: 'true', message: '请选择是否独立占地' }] : [],
			},
			{
				label: '助餐点改造日期',
				prop: 'constructionDate',
				type: 'date',
				format: 'YYYY年MM月DD日',
				valueFormat: 'YYYY-MM-DD',
				span: 8,
				changeField: true,
				rules: isVerify ? [{ required: 'true', message: '请选择助餐点改造日期' }] : [],
			},
			{
				label: '助餐点改造进度',
				prop: 'constructionStatus',
				propName: 'constructionStatusLabel',
				type: 'remoteSelect',
				code: 'CONSTRUCTION_STATUS',
				api: 'getDictItemList',
				filterKey: 'value',
				multiple: false,
				span: 8,
				rules: isVerify ? [{ required: 'true', message: '请选择助餐点改造进度' }] : [],
			},

			{
				label: '睦邻点改造日期',
				prop: 'neighborlyConstructionDate',
				type: 'date',
				format: 'YYYY年MM月DD日',
				valueFormat: 'YYYY-MM-DD',
				span: 8,
				changeField: true,
				rules: isVerify ? [{ required: 'true', message: '请选择睦邻点改造日期' }] : [],
			},
			{
				label: '睦邻点改造进度',
				prop: 'neighborlyConstructionStatus',
				propName: 'neighborlyConstructionStatusLabel',
				type: 'remoteSelect',
				code: 'CONSTRUCTION_STATUS',
				api: 'getDictItemList',
				filterKey: 'value',
				multiple: false,
				span: 8,
				rules: isVerify ? [{ required: 'true', message: '请选择睦邻点改造进度' }] : [],
			},

			{
				label: '社区老年人认知障碍照护服务中心改造日期',
				prop: 'nurseConstructionDate',
				type: 'date',
				format: 'YYYY年MM月DD日',
				valueFormat: 'YYYY-MM-DD',
				span: 8,
				changeField: true,
				rules: isVerify ? [{ required: 'true', message: '请选择社区老年人认知障碍照护服务中心改造日期' }] : [],
			},
			{
				label: '社区老年人认知障碍照护服务中心改造进度',
				prop: 'nurseConstructionStatus',
				propName: 'nurseConstructionStatusLabel',
				type: 'remoteSelect',
				code: 'CONSTRUCTION_STATUS',
				api: 'getDictItemList',
				filterKey: 'value',
				multiple: false,
				span: 8,
				rules: isVerify ? [{ required: 'true', message: '请选择社区老年人认知障碍照护服务中心改造进度' }] : [],
			},

			{
				label: '日常配送助餐点',
				prop: 'dailyDeliveryOfFoodAid',
				type: 'select',
				span: 24,
				multiple: true,
				allowCreate: true,
				filterable: true,
				changeField: false,
				noDataText: '请输入日常配送助餐点名称',
			},
			{
				label: '中心厨房灶具类型',
				prop: 'centralKitchenStoveType',
				propName: 'centralKitchenStoveTypeLabel',
				type: 'remoteSelect',
				span: 8,
				code: 'CENTRAL_KITCHEN_STOVE_TYPE',
				api: 'getDictItemList',
				filterKey: 'value',
				multiple: false,
				changeField: true,
			},
			{
				label: '使用瓶装液化气、管道天然气单位是否已安装离地不超过20CM能够正常运行的燃气泄漏安全保护装置',
				prop: 'isInstallGasLeakageSafeDevice',
				propName: 'isInstallGasLeakageSafeDeviceLabel',
				type: 'remoteSelect',
				api: 'getDictItemList',
				code: 'COMMON_FLAG',
				filterKey: 'value',
				multiple: false,
				changeField: true,
				span: 8,
			},

			{
				label: '场所性质',
				prop: 'property',
				propName: 'propertyLabel',
				type: 'remoteSelect',
				span: 8,
				code: 'FACILITIES_LOCATION_QUALITY',
				api: 'getDictItemList',
				filterKey: 'value',
				multiple: false,
				changeField: true,
				rules: isVerify ? [{ required: 'true', message: '请选择场所性质' }] : [],
			},
			{
				label: '兴办主体',
				prop: 'subject',
				propName: 'subjectLabel',
				type: 'remoteSelect',
				span: 8,
				code: 'FACILITIES_ESTABLISHMENT_MAINBODY',
				api: 'getDictItemList',
				filterKey: 'value',
				multiple: false,
				changeField: true,
				rules: isVerify ? [{ required: 'true', message: '请选择兴办主体' }] : [],
			},
			{
				label: '所处位置类型',
				prop: 'positionType',
				propName: 'positionTypeLabel',
				type: 'remoteSelect',
				code: 'FACILITY_LOCATION_TYPE',
				api: 'getDictItemList',
				filterKey: 'value',
				multiple: false,
				changeField: true,
				span: 8,
				rules: isVerify ? [{ required: true, message: '请选择所处位置类型' }] : [],
			},
			{
				label: '所在地区',
				prop: 'areas',
				propName: 'areas_name',
				type: 'AplidAreaSelect',
				span: 8,
				changeField: true,
				rules: isVerify ? [{ required: true, message: '请选择所在地区' }] : [],
			},
			{
				label: '设施详细地址',
				prop: 'address',
				maxlength: '140',
				showWordLimit: true,
				type: 'textarea',
				changeField: true,
				autosize: {
					minRows: 1,
				},
				span: 8,
				rules: isVerify ? [{ required: true, message: '请选择所处位置类型' }] : [],
			},
			{
				label: '负责人姓名',
				prop: 'personName',
				maxlength: '20',
				showWordLimit: true,
				type: 'text',
				changeField: true,
				span: 8,
				rules: isVerify ? [{ required: true, message: '请填写负责人姓名' }] : [],
			},
			{
				label: '负责人联系方式',
				prop: 'personTelephone',
				maxlength: '11',
				showWordLimit: true,
				type: 'tel',
				changeField: true,
				span: 8,
				rules: isVerify
					? [
							{ required: true, message: '请填写负责人联系方式' },
							{ pattern: regularRule.phone, message: '请输入正确的负责人联系方式' },
					  ]
					: [],
			},
			{
				label: '负责人证件类型',
				prop: 'personCertificateType',
				propName: 'personCertificateTypeLabel',
				type: 'remoteSelect',
				api: 'getDictItemList',
				code: 'ID_CARD_TYPE',
				filterKey: 'value',
				multiple: false,
				span: 8,
				changeField: false,
			},
			{
				label: '负责人证件证号',
				prop: 'personIdCard',
				type: 'input',
				changeField: false,
				span: 8,
			},
			{
				label: '负责人学历',
				prop: 'personEducation',
				propName: 'personEducationLabel',
				type: 'remoteSelect',
				api: 'getDictItemList',
				code: 'EDUCATION',
				filterKey: 'value',
				multiple: false,
				span: 8,
				changeField: false,
			},

			{
				label: '等级',
				prop: 'standard',
				propName: 'standardLabel',
				type: 'remoteSelect',
				code: 'ORG_LEVEL',
				api: 'getDictItemList',
				filterKey: 'value',
				multiple: false,
				changeField: true,
				span: 8,
				rules: isVerify ? [{ required: true, message: '请填写设施等级' }] : [],
			},
			{
				label: '等级评定日期',
				prop: 'standardTime',
				type: 'date',
				format: 'YYYY年MM月DD日',
				valueFormat: 'YYYY-MM-DD',
				span: 8,
				changeField: true,
			},
			{
				label: '服务范围',
				prop: 'serviceScope',
				type: 'text',
				maxlength: '500',
				showWordLimit: true,
				span: 8,
				changeField: true,
			},

			{
				label: '营业状态',
				prop: 'state',
				propName: 'stateLabel',
				type: 'remoteSelect',
				code: 'BUSINESS_STATUS',
				api: 'getDictItemList',
				filterKey: 'value',
				multiple: false,
				changeField: true,
				span: 8,
				rules: [{ required: true, message: '请选择营业状态' }],
			},
			{
				label: '营业时间',
				prop: 'stateTime',
				type: 'input',
				placeholder: '例：周一至周五 6:00-19:00',
				span: 8,
			},
			{
				label: '单位建立日期',
				prop: 'foundDate',
				type: 'date',
				format: 'YYYY年MM月DD日',
				valueFormat: 'YYYY-MM-DD',
				changeField: true,
				span: 8,
				labelPosition: 'top',
				rules: [{ required: true, message: '请选择单位建立日期' }],
			},
			{
				label: '图片介绍',
				prop: 'pictureIntroduction',
				type: 'upload',
				labelPosition: 'top',
				listType: 'picture-card',
				showFileList: true,
				limit: 4,
				multiple: false,
				span: 24,
			},
			{
				label: '文字介绍',
				labelPosition: 'top',
				prop: 'introduce',
				showWordLimit: true,
				type: 'textarea',
				height: '20rem',
				rules: [{ required: true, message: '请输入文字介绍' }],
				span: 24,
			},
			{
				label: '备注',
				prop: 'note',
				maxlength: '1000',
				showWordLimit: true,
				type: 'textarea',
				span: 8,
				autosize: {
					minRows: 1,
				},
			},
			{
				label: '备案日期',
				prop: 'recordFilingDate',
				type: 'date',
				format: 'YYYY年MM月DD日',
				valueFormat: 'YYYY-MM-DD',
				changeField: true,
				span: 8,
			},
			{
				label: '备案单位',
				prop: 'filingUnit',
				maxlength: '120',
				showWordLimit: true,
				type: 'text',
				span: 8,
			},
			{
				label: '备案材料',
				prop: 'filingMaterials',
				type: 'upload',
				fileType: uploadType.fileMetaType,
				listType: 'text',
				labelPosition: 'top',
				showFileList: true,
				limit: 9,
				multiple: true,
				span: 24,
			},
			{
				label: '是否为社会力量运营',
				prop: 'societyOperation',
				propName: 'societyOperationLabel',
				type: 'remoteSelect',
				code: 'COMMON_FLAG',
				api: 'getDictItemList',
				filterKey: 'value',
				multiple: false,
				span: 8,
				changeField: true,
				rules: isVerify ? [{ required: true, message: '请选择是否为社会力量运营' }] : [],
			},
			{
				label: '运营单位名称',
				prop: 'unitNameCreditCode',
				propName: 'unitName',
				type: 'autoSelect',
				api: 'dpServiceOrgHome_page',
				filterKey: 'uniqueValue',
				filterLabel: 'orgHomeName',
				multiple: false,
				changeField: true,
				paramsObj: {
					isWithAuth: 0,
				},
				rules: [{ required: true, message: '请选择运营单位' }],
				span: 8,
				change: (item, form, value) => {
					if (item.creditCode) form.creditCode = item.creditCode
				},
			},
			{
				label: '运营统一社会信用代码',
				prop: 'creditCode',
				maxlength: '18',
				showWordLimit: true,
				type: 'text',
				changeField: true,
				disabled: true,
				rules: isVerify
					? [
							{ required: true, message: '请输入统一社会信用代码' },
							{ pattern: regularRule.code, message: '请输入正确的运营统一社会信用代码' },
					  ]
					: [],
				span: 8,
			},
			{
				label: '门头照',
				prop: 'doorHead',
				type: 'upload',
				labelPosition: 'top',
				showFileList: false,
				limit: 1,
				multiple: false,
				span: 8,
				rules: isVerify ? [{ required: true, message: '请填入门头照' }] : [],
			},
			{
				label: '建筑面积',
				prop: 'floorArea',
				type: 'input',
				append: '平方米',
				isNum: true,
				span: 8,
				rules: [{ validator: regularRule.number, message: '请输入正确的数量' }],
			},
			{
				label: '占地面积',
				prop: 'coverArea',
				type: 'input',
				append: '平方米',
				isNum: true,
				span: 8,
				rules: [{ validator: regularRule.number, message: '请输入正确的数量' }],
			},

			{
				label: '区级民政部门认定挂牌照片',
				prop: 'listingPhoto',
				type: 'upload',
				listType: 'picture-card',
				labelPosition: 'top',
				showFileList: true,
				disabled: true,
				limit: 9,
				multiple: true,
				span: 24,
			},
			{
				label: '施工现场照片',
				prop: 'constructionSitePhoto',
				type: 'upload',
				listType: 'picture-card',
				labelPosition: 'top',
				showFileList: true,
				disabled: true,
				limit: 9,
				multiple: true,
				span: 24,
			},
			{
				label: '施工完成照片',
				prop: 'constructionCompletePhoto',
				type: 'upload',
				listType: 'picture-card',
				labelPosition: 'top',
				showFileList: true,
				disabled: true,
				limit: 9,
				multiple: true,
				span: 24,
			},
		],
	}
}
